package com.xx.account.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xx.common.annotation.Log;
import com.xx.common.core.controller.BaseController;
import com.xx.common.core.domain.AjaxResult;
import com.xx.common.enums.BusinessType;
import com.xx.account.domain.AccountBoss;
import com.xx.account.service.IAccountBossService;
import com.xx.common.utils.poi.ExcelUtil;
import com.xx.common.core.page.TableDataInfo;

/**
 * 老板Controller
 *
 * @author ruoyi
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/account/boss")
public class AccountBossController extends BaseController
{
    @Autowired
    private IAccountBossService accountBossService;

    /**
     * 查询老板列表
     */
    @PreAuthorize("@ss.hasPermi('account:boss:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountBoss accountBoss)
    {
        startPage();
        List<AccountBoss> list = accountBossService.selectAccountBossList(accountBoss);
        return getDataTable(list);
    }

    /**
     * 导出老板列表
     */
    @PreAuthorize("@ss.hasPermi('account:boss:export')")
    @Log(title = "老板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountBoss accountBoss)
    {
        List<AccountBoss> list = accountBossService.selectAccountBossList(accountBoss);
        ExcelUtil<AccountBoss> util = new ExcelUtil<AccountBoss>(AccountBoss.class);
        util.exportExcel(response, list, "老板数据");
    }

    /**
     * 获取老板详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:boss:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(accountBossService.selectAccountBossById(id));
    }

    /**
     * 新增老板
     */
    @PreAuthorize("@ss.hasPermi('account:boss:add')")
    @Log(title = "老板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountBoss accountBoss)
    {
        return toAjax(accountBossService.insertAccountBoss(accountBoss));
    }

    /**
     * 修改老板
     */
    @PreAuthorize("@ss.hasPermi('account:boss:edit')")
    @Log(title = "老板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountBoss accountBoss)
    {
        return toAjax(accountBossService.updateAccountBoss(accountBoss));
    }

    /**
     * 删除老板
     */
    @PreAuthorize("@ss.hasPermi('account:boss:remove')")
    @Log(title = "老板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(accountBossService.deleteAccountBossByIds(ids));
    }
}
